<h1><?=$table->db->name?> » <?=$table->name?></h1>
<?=HTML::a('Back to database', 'db', 'show', $table->db->id)?>
<?=HTML::form('update_table', 'table', 'update_records', $table->id)?>
	<table>
		<tr>
			<? foreach ( $table->fields as $field ): ?>
				<th><?=$field->displayName?></th>
			<? endforeach; ?>
		</tr>
		<tr class="input">
			<? foreach ( $table->fields as $field ): ?>
				<td>
				<? if ( isset($field->reference) ): ?>
					<?=HTML::select("new[$field->name]", $field->referenceOpts(), array('useID' => true))?>
				<? elseif ( ! $field->isVirtual ): ?>
					<?=HTML::input("new[$field->name]")?>
				<? endif; ?>
				</td>
			<? endforeach; ?>
		</tr>
		<? foreach ( $table->records() as $record ): ?>
		<tr id="<?=$record['id']?>">
			<? foreach ( $table->fields as $field ): ?>
				<td>
				<? if ( isset($field->reference) ): ?>
					<?=HTML::select("record[$record[id]][$field->name]", $field->referenceOpts(), array('selected' => $record[$field->name], 'useID' => true))?>
				<? elseif ( $field->isVirtual ): ?>
					<?=$record[$field->name]?>
				<? else: ?>
					<?=HTML::input("record[$record[id]][$field->name]", array("value" => $record[$field->name]) )?>
				<? endif; ?>
				</td>
			<? endforeach; ?>
			<td>
				<?=HTML::labeledInput("Delete?", "delete[$record[id]]", array("type" => "checkbox", "value" => $record['id']))?>
				<?=HTML::labeledInput("Update?", "update[$record[id]]", array("type" => "checkbox", "value" => $record['id']))?>
			</td>
		</tr>
		<? endforeach; ?>
	</table>
	<input type="submit" value="Update">
</form>